package orthoplanner.com.google.code.eventhandlers;

import java.awt.Container;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JFrame;

import orthoplanner.com.google.code.tools.Drawable;
import orthoplanner.com.google.code.ui.AdvanceDrawablePanel;

public class DrawableDeleteHandler extends MouseAdapter {
	private final ArrayList<Drawable> drawables;
	private Container container;
	public DrawableDeleteHandler(ArrayList<Drawable> drawables,Container container) {
	this.drawables=drawables;
	this.container=container;
	}

	@Override
	public void mousePressed(MouseEvent e) {
	AdvanceDrawablePanel advP=((AdvanceDrawablePanel)((JButton)e.getSource()).getParent());	
	Drawable d=advP.getDrawable();
	drawables.remove(d);
	container.remove(advP);
	container.doLayout();
	((JFrame)container).pack();
	container.repaint();
	
	
	}
	

}
